<?php

class Application_Form_Sessionformation  extends Twitter_Bootstrap_Form_Horizontal
{
           
    public function init()
    {
    	
    	
    	
    	$decorator=array(
			    			array('ViewHelper', array('tag'   => 'div', "class"=>"controls")),
			    			array('Label' , array(  "class"=>"control-label")),
			    			'Errors',
			    			new Zend_Form_Decorator_HtmlTag(array(
			    					'tag'   => 'div', "class"=>"control-group"
			    			)
			    		)
    	);
    	 
   
    	$translate = Zend_Registry::get('Zend_Translate');
    	$translate->setLocale('fr');
    	
    	
    	
    	$formation= new Zend_Form_Element_select('formation');
    	$formation->addMultiOption("","");
    	$formation->setLabel("Formation :")
    	->setRequired(true);
    	$formation_model=new Application_Model_DbTable_Formation();
    	$formation_record=$formation_model->fetchAll();
    	$formation->addMultiOption("","");
    	if($formation_record){
    		$respons=$formation_record->toArray();
    		foreach ($respons as $value){
    			$formation->addMultiOption($value['id_for'],$value['libelle_for'] );
    		}
    	}
    	
    	$datedebpre = new Zend_Form_Element_Text('datedebpre');
    	$datedebpre->setRequired(true)
    	->setAttrib("class", "input-large");
    	$datedebpre->setLabel($translate->_('Date de debut presinscription').'* : ');
    	 
    	$datefinpre = new Zend_Form_Element_Text('datefinpre');
    	$datefinpre->setRequired(true)
    	->setAttrib("class", "input-large");
    	$datefinpre->setLabel($translate->_('Date de fin presinscription').'* : ');
    	
    	$datedeb = new Zend_Form_Element_Text('datedeb');
    	$datedeb->setRequired(true) 
    	->setAttrib("class", "input-large");
    	$datedeb->setLabel($translate->_('Date de debut session').'* : ');
    	
    	$datefin = new Zend_Form_Element_Text('datefin');
    	$datefin->setRequired(true)
    	->setAttrib("class", "input-large");
    	$datefin->setLabel($translate->_('Date de fin session').'* : ');
    	 
    	$lieu= new Zend_Form_Element_select('lieu');
    	$lieu->addMultiOption("","");
    	$lieu->setLabel("Lieu :")
    	->setRequired(true);
    	$lieu_model=new Application_Model_DbTable_Etablissement();
    	$lieu_record=$lieu_model->fetchAll();
    	$lieu->addMultiOption("","");
    	if($lieu_record){
    		$respons=$lieu_record->toArray();
    		foreach ($respons as $value){
    			$lieu->addMultiOption($value['id_etab'],$value['nom_etab'] );
    		}
    	}
    	
    	
    	$nbrper = new Zend_Form_Element_Text('nbr');
    	$nbrper->setRequired(true)
    	->setAttrib("class", "input-large");
    	$nbrper->setLabel($translate->_('Nombre de participant (Max)').'* : ');
    	
    	$etat = new Zend_Form_Element_Checkbox('etat');
    	$etat->setRequired(true)
    	->setAttrib("class", "input-large");
    	$etat->setLabel($translate->_('Etat de session').'* : ');
    	
    	$sendBt = new Zend_Form_Element_Submit('enregistrer');
    	$sendBt->setLabel('Ajouter session');
    	$sendBt->setAttrib('class', 'btn btn-info');
    	 
    	$annuler = new Zend_Form_Element_Button('Annuler');
    	$annuler->setLabel('Annuler');
    	$annuler->setAttrib('class', 'btn btn-info');
    	
    	$formation->setDecorators($decorator);
    	$lieu->setDecorators($decorator);
    	$nbrper->setDecorators($decorator);
    	$datedeb->setDecorators($decorator);
    	$datefin->setDecorators($decorator);
    	$datedebpre->setDecorators($decorator);
    	$datefinpre->setDecorators($decorator);
    	$etat->setDecorators($decorator);
    	
    	$sendBt->setDecorators(array('ViewHelper'));
    	$annuler->setDecorators(array('ViewHelper'));
    	
    	$this->addElements(array($formation,$lieu,$nbrper,$datedeb,$datefin,$datedebpre,$etat,$datefinpre,$sendBt,$annuler ));
    	
    }
}